*Ordered logit model*

ologit Position_expert_4 Seat_diff_sim Gvt_pct Interaction

*Marginal effect graph*

preserve
drawnorm MG_b1-MG_b6, n(10000) means(e(b)) cov(e(V)) clear


postutil clear
postfile mypost prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi using sim,replace

noisily display "start"
                         
local a=0

while `a'<= 100 {

{

scalar h_Seat_diff_sim=0.42899
scalar h_constant1=1
scalar h_constant2=0
scalar h_constant3=0

generate x_betahat0 = MG_b1*h_Seat_diff_sim + MG_b2*(`a') + MG_b3*h_Seat_diff_sim*(`a')+MG_b4*h_constant1+MG_b5*h_constant2+MG_b4*h_constant3
 
generate x_betahat1 = MG_b1*(h_Seat_diff_sim+10) + MG_b2*`a'+ MG_b3*(h_Seat_diff_sim+10)*(`a')+MG_b4*h_constant1+MG_b5*h_constant2+MG_b4*h_constant3 
    
gen prob0=norm(x_betahat0)

gen prob1=norm(x_betahat1)

gen diff=prob1-prob0
    
egen probhat0=mean(prob0)

egen probhat1=mean(prob1)

egen diffhat=mean(diff)
    
tempname prob_hat0 lo0 hi0 prob_hat1 lo1 hi1 diff_hat diff_lo diff_hi  

_pctile prob0, p(2.5,97.5)
scalar `lo0' = r(r1)
scalar `hi0' = r(r2)
    
_pctile prob1, p(2.5,97.5)
scalar `lo1'= r(r1)
scalar `hi1'= r(r2)  
    
_pctile diff, p(2.5,97.5)
scalar `diff_lo'= r(r1)
scalar `diff_hi'= r(r2)  

scalar `prob_hat0'=probhat0
scalar `prob_hat1'=probhat1
scalar `diff_hat'=diffhat
    
post mypost (`prob_hat0') (`lo0') (`hi0') (`prob_hat1') (`lo1') (`hi1') (`diff_hat') (`diff_lo') (`diff_hi')

}      

drop x_betahat0 x_betahat1 prob0 prob1 diff probhat0 probhat1 diffhat
local a=`a'+ 1
display "." _c

}

display ""

postclose mypost

use sim, clear

gen MV = _n-1

graph twoway line diff_hat MV, clwidth(medium) || line diff_lo  MV, clpattern(dash) clwidth(thin) clcolor(black)|| line diff_hi  MV, clpattern(dash) clwidth(thin) ||  , xlabel(0 30 60 90, labsize(3)) ylabel(-.2 0 0.2 0.4, labsize(3)) yscale(noline) xscale(noline) yline(0)legend(off) title("Marginal effect of Gain/loss seats on Parties' support to electoral reform", size(3)) subtitle("as time spent in Government changes", size(3)) xtitle("Time spent in Government", size(2.5)) ytitle("Marginal effect of Gain/loss seats", size(2.5)) xsca(titlegap(2)) ysca(titlegap(2))scheme(s2mono) graphregion(fcolor(white))